import axios from 'axios';
import { getCookie } from './index'

const request = axios.create({
    timeout: 3000,
    timeoutErrorMessage: '已超时 请重新尝试'
})

// 请求拦截
request.interceptors.request.use((config:any) => {
    if(getCookie()) {
        config.headers.authorization = getCookie()
    }

    return config
})

// 响应拦截
request.interceptors.response.use((config) => {
    return config.data
}, (err) => {
    return Promise.reject(err)
})


export default request

